<template>
	<view class="my-same-trade-lists-area">
		<view class="my-same-trade-item u-padding-30" v-for="item in listDatas" :key="item.id">
			<view class="u-flex">
				<view class="u-flex u-flex-1">
					<text class="md">{{item.create_time}}</text>
					<text class="md u-padding-left-10 u-padding-right-10">发布</text>
					<u-tag text="审核中" type="warning" size="mini" v-if="item.audit_status == 0" />
					<u-tag text="审核失败" type="error" size="mini" v-if="item.audit_status == 2" />
				</view>
				<u-icon name="more-dot-fill" color="#666666" size="30" class="more-icon" v-if="item.audit_status != 0"
					@click="onActionSheet(item)"></u-icon>
			</view>
			<view class="area-bg u-border-radius-10 u-flex u-row-between u-margin-top-15 u-padding-20">
				<view class="u-flex nr">
					<text class="bold u-padding-right-10">客户需要额度 :</text>
					<text>{{item.quota ||0 }} 万</text>
				</view>
				<view class="u-flex nr">
					<text class="bold u-padding-right-10">客户城市 :</text>
					<text>{{item.city}}</text>
				</view>
			</view>
			<view class="area-bg u-border-radius-10 u-margin-top-15 u-padding-20">
				<view class="bold u-padding-right-10">客户情况 :</view>
				<view class="u-padding-top-10">
					{{item.description}}
				</view>

			</view>
			<view class="image-show-area area-bg u-margin-top-15 u-padding-10" v-if="item.images.length > 0">
				<u-image height="150rpx" :src="img" mode="aspectFill" v-for="(img, index) in item.images" :key="index"
					@click="onPreviewImage(index,item.images)" :border-radius="10"></u-image>
			</view>
			<view class="u-flex  u-color-666666 xs u-margin-top-25 u-padding-bottom-25">
				<view class="u-flex-1"></view>
				<u-icon :label="item.look_count" name="eye" size="24" label-size="24"
					class="u-padding-right-30"></u-icon>
				<u-icon :label="item.like_count" name="thumb-up" size="24" label-size="24"
					class="u-padding-right-30"></u-icon>
				<!-- <u-icon :label="33" name="chat" size="24" label-size="24"></u-icon> -->
			</view>
		</view>

		<u-empty v-if="listDatas.length <= 0" class="u-padding-top-50 u-padding-bottom-50" text="暂无数据"
			mode="list"></u-empty>
	</view>
</template>

<script>
	import {
		querySameTradeListsMy,
		querySameTradeListsDel
	} from '@/yixu/api/network_square';
	import {
		loadingType
	} from "@/utils/type";
	import {
		loadingFun
	} from "@/utils/tools"
	export default {
		data() {
			return {
				page: 1,
				listDatas: [],
				initStatus: false,
				loadingStatus: loadingType.LOADING,
			}
		},

		created() {
			this.queryListsDatas()
		},
		methods: {
			onActionSheet(item) {
				let _this = this;
				uni.showActionSheet({
					itemList: [
						'编辑',
						'删除',
					],
					success(res) {
						// console.log(res);
						if (res.tapIndex == 0) {
							uni.setStorageSync('same_trade_item', item);
							uni.navigateTo({
								url: `/yixu/pages/publish/order?id=${item.id}&edit=1`
							})
						}

						if (res.tapIndex == 1) {
							uni.showModal({
								title: '提示',
								content: '确认删除吗？',
								async success(res) {
									if (res.confirm) {
										try {
											await querySameTradeListsDel({
												id: item.id
											});
											_this.clearDatas();
											_this.queryListsDatas();
										} finally {

										}
									}
								}
							})
						}
					}
				})
			},
			onPreviewImage(index, urls) {
				uni.previewImage({
					urls: urls,
					current: index
				})
			},
			clearDatas() {
				this.page = 1;
				this.listDatas = [];
				this.loadingStatus = loadingType.LOADING;
			},
			queryListsDatas() {
				let requestParams = {

				}
				let {
					page,
					listDatas,
					loadingStatus
				} = this;
				loadingFun(querySameTradeListsMy, page, listDatas, loadingStatus, requestParams).then(res => {
					console.log(res)
					if (res) {
						this.page = res.page;
						this.listDatas = res.dataList
						this.loadingStatus = res.status
						console.log(listDatas)
						if (!this.initStatus) {
							this.$emit('initComplete')
							this.initStatus = true
						}

					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.area-bg {
		border-radius: 10rpx;
	}

	.image-show-area {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		grid-gap: 10rpx;
	}

	.my-same-trade-item {
		border-bottom: 2rpx solid #F5F5F5;

		&:last-child {
			border-bottom-color: transparent;
		}
	}

	.more-icon {
		transform: rotate(90deg);
	}

	.area-bg {
		background: #F7F7F7;
	}
</style>